package cn.wanda.bi.sunshine.platform.server.client.wrapper;

import cn.wanda.bi.sunshine.platform.server.aspect.AccessTimes;
import cn.wanda.bi.sunshine.platform.server.client.FFanLiveClient;
import cn.wanda.bi.sunshine.platform.server.client.IMCClient;
import cn.wanda.bi.sunshine.platform.server.client.request.AuthRequest;
import cn.wanda.bi.sunshine.platform.server.client.request.IMCAuthRequest;
import cn.wanda.bi.sunshine.platform.server.controller.response.common.SimpleResponse;
import cn.wanda.bi.sunshine.platform.server.utils.JsonUtil;
import cn.wanda.bi.sunshine.platform.server.utils.exception.ClientException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * Created by wangfupeng1
 */
@Component
public class IMCClientWrapper {

    @Autowired
    private IMCClient imcClient;

    /**
     * 万信登录校验
     */
    @AccessTimes
    public SimpleResponse imcAuthUser(IMCAuthRequest request) {
        SimpleResponse response =
                JsonUtil.toObject(imcClient.v1AuthUser(request),SimpleResponse.class);
        if (response.getStatus() != 200)
            throw new ClientException(response.getStatus(), response.getMessage());
        return response;
    }

    public SimpleResponse v1AuthUserCheckToken(String token) {
        SimpleResponse response =
                JsonUtil.toObject(imcClient.v1AuthUserCheckToken(token),SimpleResponse.class);
        if (response.getStatus() != 200)
            throw new ClientException(response.getStatus(), response.getMessage());
        return response;
    }
    

    public SimpleResponse v1AuthUserAccessToken(String token, String path) {
        SimpleResponse response =
                JsonUtil.toObject(imcClient.v1AuthUserAccessToken(token, path),SimpleResponse.class);
        if (response.getStatus() != 200)
            throw new ClientException(response.getStatus(), response.getMessage());
        return response;
    }
    
}
